#!/bin/sh
# 24.09.2008
# My own specific hook to handle the suspend AC adapter state.
# TODO: Merge with 93pm-switch.
on_ac_adapter_action() {
    hdparm -B 255 -S 240 /dev/sda
    echo 0 > /proc/sys/vm/laptop_mode
    echo 10 > /proc/sys/vm/dirty_ratio
    echo 5 > /proc/sys/vm/dirty_background_ratio
    echo 500 > /proc/sys/vm/dirty_writeback_centisecs
    logger "${0}: AC adapter is ON"
}
#
off_ac_adapter_action() {
    hdparm -B 196 -S 24 /dev/sda
    echo 5 > /proc/sys/vm/laptop_mode
    echo 40 > /proc/sys/vm/dirty_ratio
    echo 10 > /proc/sys/vm/dirty_background_ratio
    echo 1500 > /proc/sys/vm/dirty_writeback_centisecs
    logger "${0}: AC adapter is OFF"
}

case "$1" in
	thaw|resume)
	if on_ac_power
		then
			on_ac_adapter_action >/dev/null 2>&1
		else
			off_ac_adapter_action >/dev/null 2>&1
	fi
		;;
	*)
		;;
esac

#exit $NA
